// 泛型

// 方法泛型写在方法名后面, 类泛型写在类名后面
function createArray<T>(length: number, value: T): T[] {
    let result: T[] = [];
    for (let i = 0; i < length; i++) {
        result[i] = value;
    }
    return result;
}

class GenericNumber<T> {
    zeroValue: T;

    constructor(zero: T) {
        this.zeroValue = zero;
    }
}

function identity<T extends number>(arg: T): T {
    return <T>(arg * 2);
}